package com.boyaa.shells.tool 
{
	import com.boyaa.shells.control.LayerManager;
	import com.boyaa.shells.GameConfig;
	import com.boyaa.shells.view.GetProp;
	import flash.display.MovieClip;
	import flash.text.TextField;
	import gs.TweenLite;
	
	/**
	 * 文字提示
	 * * @author fly
	 */
	public class Tiptext
	{
		private static var _tipText:Tiptext;
		
		private var _tween:TweenLite;
		
		private var _view:MovieClip;
		
		public function Tiptext(str:String , _x:int = 0, _y:int = 0 , delayTime:int = 1) 
		{
			if (_tipText != null) {
				_tipText.clear();
			}
			_tipText = this;
			_view = GetProp.getResourceByName("ViewTiptext");
			var txt:TextField = _view.txt;
			txt.height = 150;
			txt.htmlText = "<b>"+str +"</b>";
			LayerManager.instance.addToLayer(LayerManager.textTipsLayer, _view);
			
			_view.x = GameConfig.DIMENSIONS.x / 2 + _x;
			_view.y = GameConfig.DIMENSIONS.y / 2 - 80 + _y;
			
			_tween = TweenLite.to(_view, 1,  { alpha:0, delay:delayTime , onComplete:function():void { 
													clear();
													}} );
		}
		
		public function clear():void
		{
			TweenLite.removeTween(_tween);
			_tween = null;
			_view.txt.text = "";
			_view.parent && _view.parent.removeChild(_view);
			ContainerClear.removeAllChild(_view);
			_view = null;
			_tipText = null;
			
		}
		
	}
	
}